<HTML><HEAD><TITLE>get_stream_info(+Stream, ?Attr, -Value)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Stream I/O</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>get_stream_info(+Stream, ?Attr, -Value)</H1>
Succeeds if the attribute Attr of the open stream Stream has the value
Value.


<DL>
<DT><EM>Stream</EM></DT>
<DD>Atom or integer denoting an open stream.
</DD>
<DT><EM>Attr</EM></DT>
<DD>Atom or variable.
</DD>
<DT><EM>Value</EM></DT>
<DD>Variable, atom, string or integer.
</DD>
</DL>
<H2>Description</H2>
   Used to retrieve information associated to an open stream.  The
   available attributes and their meanings are:

<P>
<PRE>
    Attr            Value         Description

    aliases         integer       current number of symbolic names

    compress        on, off       a hint for output operations (e.g.
                                  write_exdr/2) to use a more compact
                                  output format (output streams only).
                                  Default: on (file,pipe,socket) or off.

    connection      atom          identification of the connected
                                  socket - file name for unix sockets,
                                  host name for internet ones

    device          file, null,   the device behind the stream
                    pipe, queue,
                    socket, tty,
                    string

    end_of_line     lf, crlf      which end-of-line sequence to write
                                  (output streams only)

    event           atom or        event on writing to empty stream
                    event handle  (see open/4)

    fd              integer       the associated OS/UNIX file descriptor

    flush           flush,        explicit or implicit flushing
                    end_of_line   (output streams only)

    last_written    integer       character code of last written character
                                  (output streams only)

    line            integer       current line number
                                  (input streams only)

    mode            read, write,  the stream's direction
                    update

    name            atom or       associated filename, or contents
                    string        (in case of a string or queue), or
                                  pseudo file name (user, error, null)

    macro_expansion on, off       expand term macros (input streams only)

    offset          integer       current position in the
                                  stream, as given by at/2

    output_options  list          default output options for all term
                                  output on this stream. The list
                                  format is as in write_term/2,3.

    physical_stream integer       associated stream number

    port            integer       port number associated with an
                                  internet socket

    prompt          string        prompt string (input streams only)

    prompt_stream   integer       output stream for the prompt
                                  (input streams only)

    sigio           on            SIGIO signals enabled (UNIX only)

    system_use      on, off       a system stream is currently
                                  redirected to this stream

    usable          on, off       if the stream can currently be used:
                                  flushing or reading the empty stream
                                  may not be properly handled if `off'.

    yield           on, off       yield on end-of-file (see open/4)
</PRE>

<H3>Modes and Determinism</H3><UL>
<LI>get_stream_info(+, -, -) is multi
<LI>get_stream_info(+, +, -) is semidet
</UL>
<H3>Fail Conditions</H3>
Fails if the requested attribute is not available for this stream
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>Stream is not instantiated.
<DT><EM>(5) type error </EM>
<DD>Stream is neither an atom nor an integer.
<DT><EM>(5) type error </EM>
<DD>Attr is instantiated, but not to an atom.
<DT><EM>(5) type error </EM>
<DD>Value is instantiated, but not to an atom, string or    integer.
<DT><EM>(6) out of range </EM>
<DD>Attr is an atom, but not a valid attribute name.
<DT><EM>(193) illegal stream specification </EM>
<DD>Stream does not denote an open stream.
</DL>
<H2>Examples</H2>
<PRE>
Success:
    [eclipse]: get_stream_info(input,X,Y), writeln(X is Y), fail.
    name is user
    physical_stream is 0
    aliases is 2
    system_use is on
    line is 1
    offset is 0
    prompt is  
    prompt_stream is 1
    fd is 0
    reprompt_only is off
    device is tty
    mode is read
    usable is on
    macro_expansion is on

    no (more) solution.
    [eclipse]: get_stream_info(toplevel_input, prompt, P).

    P = "\t"
    yes.

Fail:
    get_stream_info(output, prompt, P).
    get_stream_info(output, system_use, off).

Error:
    get_stream_info(X, Y, Z).                      (Error 4)
    get_stream_info(file(f), Y, Z).                (Error 5)
    get_stream_info(output, 7, X).                 (Error 5)
    get_stream_info(output, offset, 8.5).          (Error 5)
    get_stream_info(output, length, Z).            (Error 6)
    get_stream_info(nostream, Y, Z).               (Error 193)



</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/iostream/set_stream_property-3.html">set_stream_property / 3</A>, <A HREF="../../kernel/iostream/open-3.html">open / 3</A>, <A HREF="../../kernel/iostream/open-4.html">open / 4</A>, <A HREF="../../kernel/iostream/current_stream-1.html">current_stream / 1</A>, <A HREF="../../kernel/iostream/get_stream_info-3.html">get_stream_info / 3</A>, <A HREF="../../kernel/iostream/get_stream-2.html">get_stream / 2</A>, <A HREF="../../kernel/iostream/at-2.html">at / 2</A>, <A HREF="../../kernel/ioterm/write_term-2.html">write_term / 2</A>, <A HREF="../../kernel/ioterm/write_term-3.html">write_term / 3</A>
</BODY></HTML>
